package com.aptech.yuanhuabao.ui.main.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.aptech.yuanhuabao.R;
import com.aptech.yuanhuabao.ui.main.bean.TabEntity;
import com.flyco.tablayout.CommonTabLayout;
import com.flyco.tablayout.listener.CustomTabEntity;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.jaydenxiao.common.base.BaseActivity;

import java.util.ArrayList;

import butterknife.BindView;


public class MainActivity extends BaseActivity {

    @BindView(R.id.tab_layout)
    CommonTabLayout tabLayout;

    private String[] mTitles = {"联系", "拨号盘","通讯录","会议室"};
    private int[] mIconUnselectIds = {
            R.mipmap.ic_home_normal,R.mipmap.ic_girl_normal,R.mipmap.ic_video_normal,R.mipmap.ic_care_normal};
    private int[] mIconSelectIds = {
            R.mipmap.ic_home_selected,R.mipmap.ic_girl_selected, R.mipmap.ic_video_selected,R.mipmap.ic_care_selected};
    private ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>();

    public static void startAction(Activity activity) {

        Intent intent = new Intent(activity, MainActivity.class);
        activity.startActivity(intent);

    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void initView() {
        initTab();
    }

    private void initTab(){
        for(int i=0; i<mTitles.length;i++){
            mTabEntities.add(new TabEntity(mTitles[i], mIconSelectIds[i],mIconUnselectIds[i]));
        }
        tabLayout.setTabData(mTabEntities);
        tabLayout.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
                switchFragment(position);
            }

            @Override
            public void onTabReselect(int position) {

            }
        });

        tabLayout.showMsg(0,2);
        tabLayout.showMsg(1,55);
        tabLayout.showMsg(2,100);
        tabLayout.setMsgMargin(1, -5, 5);
    }

    private void switchFragment(int position){
        tabLayout.hideMsg(position);
    }


}
